package lab02.test11;

public class Square extends Rectangle {
    double sidelength;

    //构造正方形方法，空参
    public Square(){

    }
    public Square(double sidelength){
        this.sidelength = sidelength;
    }

    public double getSidelength() {
        return sidelength;
    }

    public void setSidelength(double sidelength) {
        this.sidelength = sidelength;
    }
    public  double getDiagonal(){
        double diagonal = Math.sqrt(width*width+height*height);
        return  diagonal;
    }
    public void printMyWay(){
        super.printMyWay();
        System.out.println("边长："+width+" "+"对角线长："+getDiagonal());
    }
}
